<?php

/**
 * glossary.inc.php // glossary
 *
 * @version $Id: glossary.inc.php,v 1.6 2005/01/05 13:36:39 phppc Exp $
 * @copyright 2003 
 **/

// Formularwerte
 
$this->uf_field[1] = "title";
	$this->uf_input[1]["ml"] = 50;
	$this->uf_input[1]["size"] = 20;
$this->uf_field[2] = "content";
	$this->uf_input[2]["type"] = "textarea";
	$this->uf_input[2]["cols"] = 50;
	$this->uf_input[2]["rows"] = 7;

$glossary = $this->fun_sg2var("glossary"); // Speicherung von $_GET["glossary"] und $_POST["glossary"] als $glossary
$glossary = $this->uf_form_conf_def($glossary,array("show","edit","do_edit","new","del"),"show"); // Zulassen von bestimmten Werten, ansonsten Standardwert

$this->module_new_value["action"] = "glossary";

if ($glossary == "show") {
    $erg = $this->db_abfrage_q("SELECT id,title FROM ".$this->config["db_table_glossary"]."");
    $glossary_ones = "";
	while($db_glossary = $this->db_abfrage_fetch($erg)){
		$edit_link = $this->fun_make_link("admin.php","glossary=edit&g_id=".$db_glossary["id"]."");
		$this->tpl_load("glossary_one","admin/");
		$this->tpl_replace_vars(array("glossary_title" => $db_glossary["title"], "edit_link" => $edit_link, "glossary_id" => $db_glossary["id"]));		
		$glossary_ones .= $this->tpl_output();
	} // while
	$hidden_array["glossary"] = "new";
	$glossary_new_form = $this->uf_create_complete_form("admin_glossary_new_title",$hidden_array,"admin_glossary_new_submit","form_reset","complete_form","uf/","admin.php","","admin_glossary_","text","icreator_one","uf/");
	$hidden_array["glossary"] = "del";
	$hidden_form = $this->uf_create_hidden_form($hidden_array);
	$this->tpl_load("glossary","admin/");
	$this->tpl_replace_vars(array("hidden_form" => $hidden_form, "glossary_ones" => $glossary_ones, "glossary_new_form" => $glossary_new_form));
	$nc_main = $this->tpl_output();
}elseif ($glossary == "new") {
	list($input_array,$abfrage1,$abfrage2) = $this->uf_create_array_conf("insert");
	if ($this->uf_form_conf($input_array) == 1) {
		$erg = $this->db_abfrage_q("INSERT ".$this->config["db_table_glossary"]." ($abfrage1) VALUES ($abfrage2)");
		if($erg) {
			$this->message_green[] = 20;
			$this->w_leitung["url"] = $this->fun_make_link("admin.php","action=glossary&glossary=show");
			$this->w_leitung["number"] = 1;
		}
	}else {
		$this->message_red[] = 1;
		$this->w_leitung["number"] = 1;
	}
}elseif ($glossary == "edit") {
	$hidden_array["glossary"] = "do_edit";
	$hidden_array["g_id"] = $_GET["g_id"];
	$var_array = $this->db_abfrage_az("SELECT title,content FROM ".$this->config["db_table_glossary"]." WHERE id=\"".$_GET["g_id"]."\"");
	$nc_main = $this->uf_create_complete_form("admin_glossary_edit_title",$hidden_array,"admin_glossary_edit_submit","form_reset","complete_form","uf/","admin.php",$var_array,"admin_glossary_","text","icreator_one","uf/");
}elseif ($glossary == "do_edit") {
	list($input_array,$abfrage) = $this->uf_create_array_conf("update");
	if($this->uf_form_conf($input_array) == 1) {
		$erg = $this->db_abfrage_q("UPDATE ".$this->config["db_table_glossary"]." SET $abfrage WHERE id=\"".$_POST["g_id"]."\"");
		if ($erg) {
		    $this->message_green[] = 21;
			$this->w_leitung["url"] = $this->fun_make_link("admin.php","action=glossary&glossary=show");
			$this->w_leitung["number"] = 1;
		}
	}
}elseif ($glossary == "del") {
	if(!empty($_POST["del_glossary"])) {
		$abfrage_where_part = $this->uf_create_where_part($_POST["del_glossary"]);
		$erg = $this->db_abfrage_q("DELETE FROM ".$this->config["prefix"]."glossary WHERE $abfrage_where_part");
		if ($erg) {
		    $this->message_green[] = 22;
			$this->w_leitung["number"] = 1;
			$this->w_leitung["url"] = $this->fun_make_link("admin.php");
		}
	}else {
		$this->message_red[] = 17;
		$this->w_leitung["number"] = 1;
	}
}
	
?>